<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面滚动距离</title>
    <style>
        *{margin: 0;padding: 0;list-style-type: none;}
        div{
            height: 200px;
            background-color: #f66;
            font-size: 50px;
            margin: 20px;
        }
    </style>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <script>
        document.onscroll = function(e){
            //页面的滚动距离    
            console.log("top:",document.documentElement.scrollTop,"left:",document.documentElement.scrollLeft);
        }
        //获取元素的定位父级
        //offsetLeft  offsetTop


        /*
            元素的各种宽，高
                client  元素内容宽高+padding
                offset  元素内容宽高+padding+border
        */
    </script>
</body>
</html>